﻿using JmShared;
using SuperSocket.SocketBase;
using SuperWebSocket.SubProtocol;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebSocketServer.Filters;
using WebSocketServer.Utilities;

namespace WebSocketServer.Commands
{
    [LoggedInValidationFilter(Order = 0)]
    [LogTimeCommandFilter(Order = 1)]
    public class AndroidSettings : JsonSubCommand<JiveClientSession, AndroidUserSettings>
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger
(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        protected override void ExecuteJsonCommand(JiveClientSession session, AndroidUserSettings settings)
        {
            try
            {
                if (settings == null) throw new ArgumentNullException("settings", "settings is null");
                session.ChatClient.UpdateSettings(settings);
            }
            catch (Exception err)
            {
                log.Error("Exception in AndroidSettings", err);
                session.Close(CloseReason.ApplicationError);
            }
        }
    }
}
